#ifndef WRAP_TIMING_H
#define WRAP_TIMING_H

struct itimerval;
struct timeval;
struct timezonel;
struct tm;

namespace Wrap {

using time_t_ = long;

/// @see https://man7.org/linux/man-pages/man2/gettimeofday.2.html
/// @param tv The @c tv argument is a struct timeval (as specified in
/// <sys/time.h>)
/// @param tz The @c tz argument is a struct timezone
/// @return gettimeofday() return 0 for success. On error, -1 is returned and
/// errno is set to indicate the error.
/// @throw EFAULT One of @c tv or @c tz pointed outside the accessible address
/// space.
int gettimeofday_(struct timeval *tv, struct timezone *tz);

/// @see https://man7.org/linux/man-pages/man3/localtime_r.3.html
/// @return On success, localtime_r() return the address of the structure
/// pointed to by result. The remaining functions return NULL on error. On
/// error, errno is set to indicate the error.
/// @throw EOVERFLOW The result cannot be represented.
struct tm *localtime_r_(const time_t_ *timer, struct tm *tp);

/// @see https://man7.org/linux/man-pages/man2/setitimer.2.html
/// @return On success, zero is returned. On error, -1 is returned, and errno
/// is set to indicate the error.
/// @throw EFAULT @c newValue, or @c oldValue, is not valid a pointer.
/// @throw EINVAL @c which is not one of ITIMER_REAL, ITIMER_VIRTUAL, or
/// ITIMER_PROF; or (since Linux 2.6.22) one of the tv_usec fields in the
/// structure pointed to by @c newValue contains a value outside the range 0 to
/// 999999.
int setitimer_(int which, const struct itimerval *newValue, struct itimerval *oldValue);

/// @see https://man7.org/linux/man-pages/man2/time.2.html
/// @throw EFAULT @c timer points outside your accessible address space (but see
/// BUGS).
time_t_ time_(time_t_ *timer);
}


#endif